<template>
  <div>
    <city-header></city-header>
    <city-search :cities="cities"></city-search>
    <city-list :cities="cities" :letter="letter"></city-list>
    <city-word :cities="cities" @change="handleLetterChange"></city-word>
  </div>
</template>

<script>
import axios from "axios";
import CityHeader from "./CityHeader";
import CitySearch from "./CitySearch";
import CityList from "./CityList";
import CityWord from "./CityWord";
export default {
  name: "City",
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityWord
  },
  props: {},
  data() {
    return {
      cities: {},
      letter: ""
    };
  },
  watch: {},
  computed: {},
  methods: {
    getCityInfo() {
      axios.get("/mock/city1.json").then(this.handleGetCityInfoSucc);
    },
    handleGetCityInfoSucc(res) {
      // console.log(res);
      res = res.data;
      // console.log(res);
      this.cities = res.cities;
    },
    handleLetterChange(letter) {
      this.letter = letter;
      // console.log(letter);
    }
  },
  created() {},
  mounted() {
    this.getCityInfo();
  }
};
</script>
<style lang="stylus" scoped></style>